package com.aspose.cells;

import java.util.Iterator;

public class CustomDocumentPropertyCollection extends DocumentPropertyCollection {
   private WorksheetCollection a;

   CustomDocumentPropertyCollection(WorksheetCollection sheets) {
      this.a = sheets;
   }

   DocumentProperty a(String var1, Object var2) {
      zbom.a(var1, "name");
      return this.a(2, this.a(), var1, var2, false);
   }

   public DocumentProperty add(String name, String value) {
      zbom.a(name, "name");
      this.remove(name);
      return this.a(2, this.a(), name, value, false);
   }

   public DocumentProperty add(String name, int value) {
      zbom.a(name, "name");
      this.remove(name);
      return this.a(2, this.a(), name, value, false);
   }

   public DocumentProperty add(String name, DateTime value) {
      zbom.a(name, "name");
      this.remove(name);
      return this.a(2, this.a(), name, value, false);
   }

   public DocumentProperty add(String name, boolean value) {
      zbom.a(name, "name");
      this.remove(name);
      return this.a(2, this.a(), name, value, false);
   }

   public DocumentProperty add(String name, double value) {
      zbom.a(name, "name");
      this.remove(name);
      return this.a(2, this.a(), name, value, false);
   }

   public DocumentProperty addLinkToContent(String name, String source) {
      zbom.a(name, "name");
      this.remove(name);
      Name var3 = this.a.getNames().get(source);
      String var4 = "";
      if (var3 != null) {
         Range var5 = var3.s();
         if (var5 != null) {
            Cell var6 = var5.getWorksheet().getCells().checkCell(var5.getFirstRow(), var5.getFirstColumn());
            if (var6 != null) {
               var4 = var6.j();
            }
         }
      }

      DocumentProperty var7 = this.a(2, this.a(), name, var4, false);
      int var8 = var7.a() | 16777216;
      name = "?_generated_" + var7.a() + "." + var8;
      this.a(2, var8, name, source, true);
      return var7;
   }

   public void updateLinkedPropertyValue() {
      if (this != null && this.getCount() > 0) {
         Iterator var1 = this.iterator();

         while(var1.hasNext()) {
            DocumentProperty var2 = (DocumentProperty)var1.next();
            if (!var2.c() && var2.isLinkedToContent()) {
               var2.setValue(this.a.getRangeByName(var2.getSource()).getValue());
            }
         }
      }

   }

   public void updateLinkedRange() {
      if (this != null && this.getCount() > 0) {
         Iterator var1 = this.iterator();

         while(var1.hasNext()) {
            DocumentProperty var2 = (DocumentProperty)var1.next();
            if (!var2.c() && var2.isLinkedToContent()) {
               Range var3 = this.a.getRangeByName(var2.getSource());
               if (var3 != null) {
                  var3.setValue(var2.getValue());
               }
            }
         }
      }

   }

   private int a() {
      int var1 = 1;

      DocumentProperty var3;
      for(Iterator var2 = this.iterator(); var2.hasNext(); var1 = Math.max(var1, var3.b())) {
         var3 = (DocumentProperty)var2.next();
      }

      return var1 + 1;
   }
}
